package com.gjy.oracle;

import org.springframework.util.ObjectUtils;

import java.sql.*;

/**
 * @author gjy
 * @version 1.0
 * @since 2024-12-14 08:51:47
 */
public class OracleUtil {

    public static Connection getConnection() throws Exception {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        return DriverManager.getConnection("jdbc:oracle:thin:@192.168.253.136:1521/FREE",
                "system",
                "Oracle12");
    }

    public static void close(Connection connection, PreparedStatement ps, ResultSet rs) throws SQLException {
        if (!ObjectUtils.isEmpty(connection)) {
            connection.close();
        }
        if (!ObjectUtils.isEmpty(ps)) {
            ps.close();
        }
        if (!ObjectUtils.isEmpty(rs)) {
            rs.close();
        }
    }

}
